toast(var.xiangMu .. "在线版本0.0.3")
package.loaded["general"] = nil
require("general")

-----------------------私有部分--------------------------

function main1()
    nowTime1 = os.time();
    nowTime = os.time();

    -- windowsDecide()
    if var.isLuaStart == 0 then
        var.timeXXX = nowTime
        return
    end

    nowDateTime = os.date("*t")
    today = tonumber(os.date("%w", os.time()))
    muBiaoZhuanHuan() -- 公用 必须最优先
    -- if version ~= "2.2.4" then
    --     if getBacklightLevel() ~= 0.5 then
    --         setBacklightLevel(0.5);
    --     end
    -- end
    bid = frontAppBid()
    apps1 = var.appXiangMu
    -- tiaoShi(bid)
    if bid == apps1 then
        -- tiaoShi("apps1")
        APP = APP1
    elseif bid == apps2 then
        -- tiaoShi("apps2")
        APP = APP2
        -- elseif bid == appWeiXin and tmpWeiXinWeiHu ~= nil and isWeiXinWeiHu == false and nowDateTime.hour >= hourWeiXin and
        --     nowDateTime.min >= minWeiXin then
    elseif bid == "com.apple.DocumentsApp" then
        setRotationLockEnable(false);
        init(1)
    else
        -- tiaoShi("哪个都没开")
        APP.isYiDengLu = 0
        setVPNEnable(true)
        mSleep(10000)
        runApp(apps1)
        APP = APP1
        mSleep(5000)
    end

    var.m_iRunCount = var.m_iRunCount + 1

    isXiaoHao()

    zongHe()
    zongHe_Mult()
    zongHe_Screen()
    doTarget()
    timeChongZhi()
    checkXXX()
    everyDayInit()
    resetIDLETimer();
    -- timeJianGe(debug.getinfo(1).currentline)
    -- nowTime2 = os.time();
    -- dialog(nowTime2 - nowTime1,0)
    -- lua_exit()
end
-- 初次加载
function chuCiJiaZai(...)
    bianLiang()
    oncePlist()
    onceOther()

    if var.version ~= "2.2.4" then
        setBacklightLevel(0.5);
    end
    local tmpXuanXiang = string.find(var.zongHeXuanXiang1, "3") -- 网络调试
    if tmpXuanXiang ~= nil then
        local tmpXuanXiang = string.find(var.zongHeXuanXiang1, "0") -- 网段0
        if tmpXuanXiang ~= nil then
            initLog(var.wanmaoIP, 2); -- 初始化日志,并以异步方式发送；把 2 换成 3  即为同步发
            -- tiaoShi("12345到司法所f等法规到是否感受到法国"");  --将日志发送到 192.168.1.1 
            -- closeLog("192.168.0.215");
        end
        local tmpXuanXiang = string.find(var.zongHeXuanXiang1, "1") -- 网段1
        if tmpXuanXiang ~= nil then
            initLog(var.wanmaoIP, 2); -- 初始化日志,并以异步方式发送；把 2 换成 3  即为同步发
            -- tiaoShi("12345到司法所f等法规到是否感受到法国"");  --将日志发送到 192.168.1.1 
            -- closeLog("192.168.0.215");
        end
    end
    -- local isChongQi = false
    -- if not(file_exists("/private/var/mobile/Library/Filza/")) then  
    --         tiaoShi("filza")
    --         isChongQi = true      
    --         httpDown(httpMuLu.."deb/Filza.deb",file_AutoInstall.."Filza.deb")  
    -- end
    -- if not(file_exists("/private/var/lib/xcon/")) then  
    --         tiaoShi("xcon") 
    --         isChongQi = true      
    --         httpDown(httpMuLu.."deb/xcon.deb",file_AutoInstall.."xcon.deb")  
    -- end
    -- if isChongQi == true then
    --         -- dialog("重启",0)
    --         reboot()
    --         lua_exit()
    -- end 
    -- if sysint >= 800 then
    --         Applications = "Application"
    -- else
    --         Applications = "Applications"
    -- end
    -- local isYouXunLei = string.find(iTunesMetadata3,Applications)
    -- if isYouXunLei == nil then 
    --         tiaoShi("下载迅雷")
    --         init("0",0)
    --         httpDown(httpMuLu.."APP/xunlei.ipa", "/var/mobile/Documents/ipa.ipa")
    --         mSleep(2000)
    --         runFilza()
    --         mSleep(2000)
    --         runApp(appXunLei)
    --         mSleep(5000)
    --         if isColor(390,580,245,98,90,0) then
    --                 touchMoveXY(497,872,136,866)
    --                 mSleep(1000)
    --         end
    --         if isColor(398,455,245,98,90,0) then
    --                 touchMoveXY(497,872,136,866)
    --                 mSleep(1000)
    --         end
    --         if isColor(207,984,18,148,246,0) then
    --                 touchQuickly(311,981)
    --                 mSleep(1000)
    --                 if isColor(207,984,18,148,246,0) then
    --                         touchQuickly(311,981)
    --                         mSleep(1000)
    --                 end
    --         end
    --         isXunHuanLua = false
    --         isChongZhiLua = true
    --         init("0",1)
    --         return
    --         -- tmpDataPlist3 = find("/private/var/mobile/Applications/*"..file_severIP3)
    --         -- dataPlist3 = tmpDataPlist3:read("*all")
    --         -- dataPlist3a = string.sub(dataPlist3, 1, 70)
    --         -- iTunesMetadata3 = dataPlist3a.."iTunesMetadata.plist"

    -- -- else
    -- --         dialog(iTunesMetadata3,0)
    -- --         lua_exit()
    -- end

    -- if file_exists(luaMuLu..iphoneId..".txt") then
    -- else
    --     f = io.open(luaMuLu..iphoneId..".txt", 'w')
    --     f:close()
    -- end
    -- 日期早
    NowDay = loadPlist(var.luaMuLu .. var.xiangMu .. ".plist", "日期")
    if NowDay == nil then
        NowDay = nowDateTime.day
        writePlist(var.luaMuLu .. var.xiangMu .. ".plist", "日期", NowDay)
    end

    -- 日期晚
    NowDayNight = loadPlist(var.luaMuLu .. var.xiangMu .. ".plist", "日期晚")
    if NowDayNight == nil then
        NowDayNight = nowDateTime.day
        writePlist(var.luaMuLu .. var.xiangMu .. ".plist", "日期晚", NowDayNight)
    end

    -- --游戏版本
    -- local tmpGame1 = string.find(dataPlist1,Applications)
    -- if tmpGame1 == nil then  
    --         tiaoShi("下载游戏1")
    --         init("0",0)
    --         xunLeiXiaZai1(httpMuLu.."APP/"..apps1..".ipa")
    --         mSleep(2000)
    --         runFilza()
    --         mSleep(2000)
    --         init("0",1)
    --         runApp(apps1)
    --         APP1.isYiDengLu = 0
    --         mSleep(5000)
    --         touchQuickly(448,441)     --关通知
    --         mSleep(1000)
    --         touchQuickly(448,441)     --关通知
    --         mSleep(1000)
    --         isXunHuanLua = false
    --         isChongZhiLua = true
    --         return
    -- end 
    -- --游戏版本
    -- if pingTai2 ~= "10" then
    --         local tmpGame2 = string.find(dataPlist2,Applications)
    --         if tmpGame2 == nil then      
    --                 tiaoShi("下载游戏2")
    --                 init("0",0)
    --                 xunLeiXiaZai1(httpMuLu.."APP/"..apps2..".ipa")
    --                 mSleep(2000)
    --                 runFilza()
    --                 mSleep(2000)
    --                 init("0",1)
    --                 runApp(apps2)
    --                 APP2.isYiDengLu = 0
    --                 mSleep(5000)
    --                 touchQuickly(448,441)     --关通知
    --                 mSleep(1000)
    --                 touchQuickly(448,441)     --关通知
    --                 mSleep(1000)
    --                 isXunHuanLua = false
    --                 isChongZhiLua = true
    --                 return
    --         end 
    -- end
    -- --文件集中检测
    -- isFileJiZhongJianCe = loadPlist(luaMuLu..xiangMu..".plist","文件集中检测")
    -- if isFileJiZhongJianCe == nil then
    --         isFileJiZhongJianCe = false
    --         writePlist(luaMuLu..xiangMu..".plist","文件集中检测",isFileJiZhongJianCe)
    -- end
    -- --脚本故障检测
    -- -- isJiaoBenJianCe = loadPlist(luaMuLu..xiangMu..".plist","脚本故障检测")
    -- -- if isJiaoBenJianCe == nil then
    --         isJiaoBenJianCe = false
    --         writePlist(luaMuLu..xiangMu..".plist","脚本故障检测",isJiaoBenJianCe)
    -- -- end
    -- --脚本故障检测时间
    -- timeJiaoBenJianCe = loadPlist(luaMuLu..xiangMu..".plist","脚本故障检测时间")
    -- if timeJiaoBenJianCe == nil then
    --         timeJiaoBenJianCe = nowDateTime.hour..":"..nowDateTime.min
    --         writePlist(luaMuLu..xiangMu..".plist","脚本故障检测时间",timeJiaoBenJianCe)
    -- end 
    -- isWeiXin62 = loadPlist(luaMuLu .. "WeiXin.plist", "isWeiXin62")
    -- if isWeiXin62 == nil or isWeiXin62 == false then
    --     weiXinPath = appDataPath(appWeiXin);
    --     copyfile(weiXinPath .. "/Library/WechatPrivate/wx.dat",
    --         "/var/mobile/Media/TouchSprite/res/" .. iphoneId .. "_wx.dat");
    --     if string.find(zongHeXuanXiang1, "0") ~= nil then
    --         ftp.upload("/var/mobile/Media/TouchSprite/res/" .. iphoneId .. "_wx.dat", ftpMuLu .. "WeiXin/0/")
    --     else
    --         ftp.upload("/var/mobile/Media/TouchSprite/res/" .. iphoneId .. "_wx.dat", ftpMuLu .. "WeiXin/1/")
    --     end
    --     isWeiXin62 = true
    --     writePlist(luaMuLu .. "WeiXin.plist", "isWeiXin62", isWeiXin62)
    -- end
    -- isXueSe = loadPlist(luaMuLu .. xiangMu .. ".plist", "isXueSe")
    -- if isXueSe == nil then
    --     isXueSe = false
    --     writePlist(luaMuLu .. xiangMu .. ".plist", "isXueSe", isXueSe)
    -- end

    -- muBiao1 = loadPlist(luaMuLu..xiangMu..".plist","目标1")
    -- if muBiao1 == nil then
    --         muBiao1 = mb_Wu
    --         writeConfig(var.xiangMu.."_Set.dat",mbCon1,muBiao1Con)
    -- end
    -- muBiao2 = loadPlist(luaMuLu..xiangMu..".plist","目标2")
    -- if muBiao2 == nil then
    --         muBiao2 = mb_Wu
    --         writeConfig(var.xiangMu.."_Set.dat",mbCon2,muBiao2Con)
    -- end
    -- muBiao3 = loadPlist(luaMuLu..xiangMu..".plist","目标3")
    -- if muBiao3 == nil then
    --         muBiao3 = mb_Wu
    --         writeConfig(var.xiangMu.."_Set.dat",mbCon3,muBiao3Con)
    -- end
    -- numDead = loadPlist(luaMuLu .. xiangMu .. ".plist", "死亡次数")
    -- if numDead == nil then
    --     numDead = 0
    --     writePlist(luaMuLu .. xiangMu .. ".plist", "死亡次数", numDead)
    -- end

    nowTime = os.time()
    -- timeZhengLi = loadPlist(luaMuLu .. xiangMu .. ".plist", "timeZhengLi")
    -- if timeZhengLi == nil then
    --     timeZhengLi = nowTime - 10 * 60
    --     writePlist(luaMuLu .. xiangMu .. ".plist", "timeZhengLi", timeZhengLi)
    -- end

    NumDay = loadPlist(var.luaMuLu .. var.xiangMu .. ".plist", "第几天")
    if NumDay == nil then
        NumDay = 0
        writePlist(var.luaMuLu .. var.xiangMu .. ".plist", "第几天", NumDay)
    end

    tiaoShi("初次加载")
end
-- 变量及常量
function bianLiang()
    -- 固定
    nowTime = os.time();
    timeDingShiDianRenWu = nowTime - 60 * 60
    wScreen, hScreen = getScreenSize()
    var.isLuaStart = 1 -- 脚本启动
    ftpMuLu = "ftp://xinqinew:Qwer1234@1x9722733t.iask.in/"
    numYunDaMa = 0 -- 云打码
    var.timeXXX = nowTime -- 掉线检测
    nowDateTime = os.date("*t")

end
-- oncePlist
function oncePlist()

end
-- onceOther
function onceOther()
    -- path_dm_num = "https://gitee.com/xinqinew_admin/rise-of-stars/raw/master/dm_num.txt"
    -- ts.tsDownload(userPath() .. "/res/dm_num.txt", path_dm_num, {
    --     ["tstab"] = 1,
    --     ["mode"] = false
    -- })
    -- mSleep(4000)
    -- dm_num = addDmOcrDict("dm_num.txt")
    -- mSleep(2000)

    -- by新版不支持
    -- path_by_so = "https://gitee.com/xinqinew_admin/rise-of-stars/raw/master/by.so"
    -- ts.tsDownload("/usr/bin/tsplugin/by.so", path_by_so, {
    --     ["tstab"] = 1,
    --     ["mode"] = true
    -- })
    -- by = require("by")
    -- by.SetDict(dictNum, "/User/Media/TouchSprite/res/boardNumberDM.txt")

    -- floatingWindow()
    -- tab_lizi1 = {"600c00fffffffff$1$40$12$5", "600e00fffffffff$1$41$12$5", "6003003fffffffff@1$1$43$13$5",
    --              "3001c006003ffffffdffe$1$47$14$6", "6007003fffffffff@1$1$44$13$5", "3001c006003ffffffdfff$1$48$14$6",
    --              "7003800e003ffffffffff$1$51$14$6", "7000e0038007ffefffffff@10$1$52$15$6",
    --              "3000e001c007ffffffffffdfff@1$1$67$15$7", "7000e0038007ffffffffffdfff@1$1$68$15$7",
    --              "70007000e000fffefffffffffffe$1$71$16$7"}
    -- index_lizi1 = addTSOcrDictEx(tab_lizi1)

    -- tab_cd_num = {"0380781c8708c08ffffff008008$4$44$12$9", "31cfbec63841841fe37be$8$45$12$7",
    --               "603e0781f83bc73fc3383$2$42$12$7", "31cfbec63841841fe37be$8$45$12$7",
    --               "ffffff0400f03b870cc07803001$K$49$12$9", "603e0f81f83bc637c3383$2$41$12$7",
    --               "0180780e8388e08c08fff008008$4$35$12$9", "400c00ffffff$1$27$12$4", "600400c00fff$1$17$12$4",
    --               "ffffff0400f03b870cc06803$K$47$12$8", "3fcffec43841841c6363e$6$43$12$7",
    --               "607c0f81f833c637c3303$2$39$12$7", "ffffff0400f03b870cc06803$K$47$12$8",
    --               "603e0780f81b833fe3783$2$40$12$7", "004fc68438818818c38fe$5$32$12$7",
    --               "fff0400e03b871ce06803$K$36$12$7", "204606c03841841ce37be$3$32$12$7",
    --               "7fcffe843841843c6363e$6$44$12$7", "7befe6843841843ffe7be$8$49$12$7", "600400c00ffffff$1$29$12$5",
    --               "fc6fc68838818838fe87e$5$42$12$7", "fffefff801e003c00600e0783c0e00ffffff$M$76$12$12",
    --               "603e0780f81b873fe3783$2$41$12$7", "603e0780f81b873fe3783$2$41$12$7",
    --               "fffffff001e003c00600e0783c0e00ffffff$M$76$12$12", "400c00ffffff$1$27$12$4",
    --               "7befe2843841843ffe73e$8$47$12$7", "7fec62843841c43e7e$6$36$12$6", "607c0f81f833c637c3303$2$39$12$7",
    --               "fff0400e03b871ce06803$K$36$12$7", "400c00ffffff$1$27$12$4", "0080380e81c8708c08ffffff008$4$44$12$9",
    --               "400c00ffffff$1$27$12$4", "fff0400e01b871ce06803$K$35$12$7", "606e06803841843ffe7be$3$39$12$7",
    --               "607c0f81f833c637c3303$2$39$12$7", "606e06803841843ff67be$3$38$12$7",
    --               "7beff6843841843ff67be$8$49$12$7", "7c4fe6c63821821c437fe3fc$9$50$12$8",
    --               "0180380e8388608c08ffffff008$4$44$12$9", "fffe3f7801f003c00700f0783c0e00ffffff$M$76$12$12",
    --               "400c00ffffff$1$27$12$4", "600400c00ffffff$1$29$12$5", "fc6fc68838818838fe87e$5$42$12$7",
    --               "fffefff801e003c00700f0783c0e00ffffff$M$78$12$12", "400400c00ffffff$1$28$12$5",
    --               "fc6fc68c38818838fe87e$5$43$12$7", "fffffff801e003c00700f0783c0e00ffffff$M$79$12$12",
    --               "0180781c8708e08ffffff008008$4$44$12$9", "607c0f81f833c637c3303$2$39$12$7",
    --               "ffffff0400e03b871ce06803$K$48$12$8", "80080180f87ebf0f80c00$7$29$12$7",
    --               "fc6fc68838818838fe87c$5$41$12$7", "80080180f83e9f0f80c00$7$27$12$7",
    --               "fc6fc68838818838fe87e$5$42$12$7", "400c00ffffff$1$27$12$4", "603e0780f81b873fe3783$2$41$12$7",
    --               "fffe3f7801f003c00700f0783c0e00ffffff$M$76$12$12", "600400c00fff$1$17$12$4", "400400c00fff$1$16$12$4",
    --               "7beff6843841843ffe7be$8$50$12$7", "fffefff801e003c00700f0783c0e00ffffff$M$78$12$12",
    --               "400400c00ffffff$1$28$12$5", "fc6fc68c38818838fe87e$5$43$12$7",
    --               "fffffff001e003c00700f0783c0e00ffffff$M$78$12$12", "400c00ffffff$1$27$12$4",
    --               "0180781c8308e08ffffff008008$4$43$12$9", "ffffff0400f03b871ce06803$K$49$12$8",
    --               "80080180f87ebf0f80c00$7$29$12$7", "fc6fc68838818838fe87c$5$41$12$7",
    --               "80080180f87e9f0f80c00$7$28$12$7", "fc6fc68838818838fe87e$5$42$12$7", "7fee06803801803ffe$0$34$12$6",
    --               "400c00ffffff$1$27$12$4", "400c00ffffff$1$27$12$4", "7c6fe6823821823ee67fe$9$45$12$7",
    --               "fffe3f7801f003c00700f0783c0e00ffffff$M$76$12$12", "400c00ffffff$1$27$12$4",
    --               "606e06803841843ce37be$3$35$12$7", "0080380e8388708c08ffffff008$4$44$12$9",
    --               "fffefff801e003c00700f0783c0e00ffffff$M$78$12$12", "400c00ffffff$1$27$12$4",
    --               "80080180f87ebf0f80c00$7$29$12$7", "fffffff001e003c00700f0783c0e00ffffff$M$78$12$12",
    --               "203607c0f81b833ce37c3$2$38$12$7", "fc6fc68c38818838fe87e$5$43$12$7",
    --               "004fc68438818818c38fe$5$32$12$7", "ffffff0400e03b871ce06803$K$48$12$8",
    --               "80080180f87ebf0f80c00$7$29$12$7", "0080380e81c8708c08ffffff008$4$44$12$9",
    --               "80080080783f9f8fc0e00$7$29$12$7", "7fcffe843841843e6663e$6$45$12$7"}
    -- index_cd_num = addTSOcrDictEx(tab_cd_num)
    -- tab_dm_num = {"C00$.$0.0.2$2", "C01800$.$0.0.4$2", "7FFC0E00C00803FFDFF0$0$0.0.43$12", "401803FFFFF$1$0.0.27$12",
    --               "400803007FFFFE$1$0.0.28$12", "600803007FFFFE$1$0.0.29$12", "600803007FF$1$0.0.17$12",
    --               "400803007FF$1$0.0.16$12", "603C0E03C0D873FC5E08$2$0.0.41$12", "60781E07C19C62F84C08$2$0.0.39$12",
    --               "60381E07C19C62F84C08$2$0.0.38$12", "202C0F03C0D8339C5F0801$2$0.0.40$12",
    --               "603C0E07C1DC73F84E08$2$0.0.42$12", "603C1E07C1DC62F84E08$2$0.0.41$12",
    --               "603C0E03C1D873F85E08$2$0.0.41$12", "004C0F00C208419C5EF98E$3$0.0.36$12",
    --               "60780600C20863FFDEF8$3$0.0.39$12", "607C0E00C208439C5EF8$3$0.0.35$12",
    --               "60780610C20C63FFDEF0$3$0.0.40$12", "0180F07A1C4E09E1BFF804008$4$0.0.39$12",
    --               "0180F072384E09FFFFF804008$4$0.0.44$12", "0080703A1C4709813FFFFF008$4$0.0.44$12",
    --               "0180F03A1C4E09813FF804008$4$0.0.35$12", "0080703E0E4709813FFFFF008010$4$0.0.46$12",
    --               "0180F07A1C4E09FFFFF804008$4$0.0.44$12", "0080703A0E4709813FFFFF008010$4$0.0.45$12",
    --               "0180703A1C4609813FFFFF008$4$0.0.44$12", "0080701E0E4709813FFFFF008010$4$0.0.45$12",
    --               "0080703A1C4709813FFFFF008010$4$0.0.45$12", "FC7F8E30C408831FE1F8$5$0.0.43$12",
    --               "FC5F8E10C408831861F80C$5$0.0.40$12", "FC7F8E20C408831FE1F8$5$0.0.42$12",
    --               "FC5F8E10C4088318E1F8$5$0.0.38$12", "3FDFFF10C208418C58F8$6$0.0.43$12",
    --               "7FF8C610C20C43CFC8F0$6$0.0.41$12", "7FFFFE10C20843CFD8F8$6$0.0.48$12",
    --               "80100203C3FBF1F03000$7$0.0.29$12", "80100201C1F9F9F83800$7$0.0.29$12",
    --               "80100201C1F8F9F83800$7$0.0.28$12", "7BFFEE10C20843FFDEF8$8$0.0.50$12",
    --               "7BFFCE10C20863FFDEF8$8$0.0.50$12", "7BFFC610C20843FFDCF8$8$0.0.47$12",
    --               "31DF7F18C20841FC5EF804$8$0.0.46$12", "7BFFFE10C20843FCDEF8$8$0.0.49$12",
    --               "01CF7F38C208419C5EF98E$8$0.0.46$12", "7C7FCE08C10823DCDFF8$9$0.0.45$12",
    --               "7C5FCF18C10821885FF9FE$9$0.0.50$12", "7C5FCE18C10821885FF8FC$9$0.0.47$12",
    --               "FFE080381DC71DC0E008$K$0.1.37$12", "FFFFFC100783B8E1B01C01$K$0.1.49$12",
    --               "FFFFFC100783B8E1B01C01$K$0.1.48$12", "FFFC7DE00F803C00C0383C3C1C03FFFFF$M$0.0.76$12",
    --               "FFFDFFE00F003C00C0383C3C1C03FFFFF$M$0.0.78$12", "FFFFFFC00F003C00C0383C3C1C03FFFFF$M$0.0.78$12",
    --               "FFFCFDE00F803E00C0383C3C1C03FFFFF$M$0.0.78$12", "FFFFFFE00F003C00C0383C3C1C03FFFFF$M$0.0.79$12",
    --               "FFFDFFE00F003C00C0383C3C1C03FFFFF$M$0.0.76$12", "FFFFFFC00F003C00C0383C3C1C03FFFFF$M$0.0.76$12",
    --               "FFFDFFE00F803C00C0383C3C1C03FFFFF$M$0.0.79$12"}
    -- index_dm_num = addTSOcrDictEx(tab_dm_num)
    -- tab_num = {"600c00fffffffff$1$40$12$5", "3fcffefffc03803c03fff7fe$0$64$12$8", "703f0fc1f83bc73fe37c3$2$49$12$7",
    --            "01c7befffce3863ce3fff7be008$8$65$12$9", "fe6fe7cc3c83cc3cffcfe038$5$58$12$8", "ff@1$.$9$3$3",
    --            "c00c00c03c1fcffff8fc0e00$7$43$12$8", "60ee0fe07c63c63ce3fff7be$3$58$12$8",
    --            "7fefffc63c43ce3e7fe7e23c$6$64$12$8", "01c07c0fc3ccf8ce0cffffff00c$4$58$12$9",
    --            "fffffffff1f03f871ee0fc07801$K$69$12$9", "fffffffc03f007e00f01f0fc7f0f80ffffff$M$93$12$12",
    --            "f@1$,$5$5$1", "3807eefefc63863c63fffffe3fc$9$71$12$9"}
    -- tab_num = {"600c00fffffffff$1$40$12$5", "3fcffefffc03803c03fff7fe$0$64$12$8", "703f0fc1f83bc73fe37c3$2$49$12$7",
    --            "01c7befffce3863ce3fff7be008$8$65$12$9", "fe6fe7cc3c83cc3cffcfe038$5$58$12$8",
    --            "c00c00c03c1fcffff8fc0e00$7$43$12$8", "60ee0fe07c63c63ce3fff7be$3$58$12$8",
    --            "7fefffc63c43ce3e7fe7e23c$6$64$12$8", "01c07c0fc3ccf8ce0cffffff00c$4$58$12$9",
    --            "3807eefefc63863c63fffffe3fc$9$71$12$9"}
    -- index_num = addTSOcrDictEx(tab_num)

    -- haoLV = 0
    -- local tmpXiaoHao = string.find(var.zongHeXuanXiang2, "6") -- 小号
    -- local tmpChengPinHao = string.find(var.zongHeXuanXiang2, "5") -- 成品号
    -- local tmpDaHao = string.find(var.zongHeXuanXiang2, "4") -- 大号
    -- if tmpXiaoHao ~= nil then
    --     haoLV = 1
    -- end
    -- if tmpChengPinHao ~= nil then
    --     haoLV = 2
    -- end
    -- if tmpDaHao ~= nil then
    --     haoLV = 3
    -- end

    -- current_time = os.date("%m-%d_%H.%M", os.time());
    -- snapshot(iphoneId .. "-" .. current_time .. ".png", 0, 0, 1135, 639); -- 以时间戳命名进行截图
    -- ftpUpPNG(iphoneId .. "-" .. current_time .. ".png", "PNG/")

end

-- 综合
function zongHe(...)
    if inside() then
        checkRed()
    end
    if isColor(459, 80, 0xd28425, 95) and isColor(533, 73, 0xa07953, 95) and isColor(986, 100, 0x804037, 95) and
        isColor(810, 528, 0xfeaa22, 95) then
        tiaoShi("邮件界面")
        if isColor(1051, 156, 0xaf070c, 95) then -- 系统红点
            tiaoShi("系统红点")
            touchClick(759, 536, 0xb96c2f)
        else
            -- tap(988, 101)
            touchClick(988, 101, 0x864137)
        end
    end
    if isColor(97, 223, 0x2d231d, 95) and isColor(267, 222, 0xf6e6bd, 95) and isColor(267, 304, 0xe9daaf, 95) then
        tiaoShi("进入江湖")
        touchClick(966, 569, 0xee916b)
    end
    if isColor(506, 384, 0x25b99c, 95) and isColor(632, 410, 0xf8c748, 95) then
        tiaoShi("排队")
        var.timeXXX = nowTime
    end
    if isColor(1098, 64, 0x81453b, 95) and isColor(1099, 75, 0xe9bf81, 95) and isColor(691, 50, 0xebdea3, 95) then
        tiaoShi("note")
        -- setVPNEnable(false)
        touchClick(1098, 64)
    end
    if isColor(1018, 29, 0xffffff, 95) and isColor(1028, 29, 0x070707, 95) and isColor(1090, 267, 0x7f7041, 95) then
        tiaoShi("please check the notice")
        -- setVPNEnable(false)
        touchClick(1018, 29)
    end
    if isColor(412, 176, 0xe9bc41, 95) and isColor(490, 162, 0x000000, 95) and isColor(1089, 365, 0xffe881, 95) then
        tiaoShi("进入游戏")
        local flag = getVPNStatus()
        if flag.active then
            setVPNEnable(false)
        end
        touchMoveXY(79, 573, 79, 190)
        touchClick(560, 510)
        var.timeXXX = nowTime
    end
end
-- 综合--多点
function zongHe_Mult(...)
    -- x, y = findMultiColorInRegionFuzzy(0xffde8c, "-43|-3|0xbd834d,-1|-44|0xc68852", 90, 0, 0, 1136, 640, {
    --     orient = 5
    -- })
    -- if x ~= -1 then
    --     -- 右下
    --     tiaoShi("右下")
    --     touchClick(x + 20, y + 20)
    --     return true
    -- end
    -- x, y = findMultiColorInRegionFuzzy(0xffdd85, "-1|-33|0xcfad66,-33|1|0xcc9856", 90, 0, 0, 1136, 640, {
    --     orient = 5
    -- })
    -- if x ~= -1 then
    --     tiaoShi("右下2")
    --     touchClick(x + 20, y + 20)
    --     return true

    -- end
    -- x, y = findMultiColorInRegionFuzzy(0xffdc83, "2|-41|0xe8b07c,40|-3|0xbe8e63", 90, 0, 0, 1136, 640, {
    --     orient = 8
    -- })
    -- if x ~= -1 then
    --     -- 左下
    --     tiaoShi("左下")
    --     touchClick(x - 20, y + 20)
    --     return true
    -- end
    -- x, y = findMultiColorInRegionFuzzy(0xffdc87, "1|-36|0xc18349,41|0|0xc68551", 90, 0, 0, 1136, 640, {
    --     orient = 8
    -- })
    -- if x ~= -1 then
    --     -- 左下
    --     tiaoShi("左下2")
    --     touchClick(x - 20, y + 20)
    --     return true
    -- end
    -- -- x, y = findMultiColorInRegionFuzzy(0xffdc87, "-24|0|0xecb46c,0|22|0xe8b671", 90, 0, 0, 1136, 640, {
    -- --     orient = 2
    -- -- })
    -- -- if x ~= -1 then
    -- --     -- 右上
    -- --     tiaoShi("右上")
    -- --     touchClick(x + 20, y - 20)
    -- --     return true
    -- -- end
    -- x, y = findMultiColorInRegionFuzzy(0xffde8b, "3|41|0xc38f60,36|2|0xc4a174", 90, 0, 0, 1136, 640, {
    --     orient = 1
    -- })
    -- if x ~= -1 then
    --     -- 左上
    --     tiaoShi("左上")
    --     touchClick(x - 20, y - 20)
    --     return true
    -- end
    -- x, y = findMultiColorInRegionFuzzy(0xffdc86, "1|44|0xb6855c,43|1|0xb27c4d", 90, 0, 0, 1135, 639, {
    --     orient = 1
    -- })
    -- if x ~= -1 then
    --     -- 左上
    --     tiaoShi("左上2")
    --     touchClick(x - 20, y - 20)
    --     return true
    -- end
    -- x, y = findMultiColorInRegionFuzzy(0xffde88, "-44|3|0xb98454,-4|44|0xb88456", 90, 0, 0, 1135, 639, {
    --     orient = 4
    -- })
    -- if x ~= -1 then
    --     tiaoShi("右上")
    --     touchClick(x + 20, y - 20)
    --     return true
    -- end
    -- return false
end
-- 综合--屏幕乱点
function zongHe_Screen()
    -- if isColorPlus(18, 24, 0xafafaf, 95) and isColorPlus(7, 24, 0xaf4600, 95) then
    --     screenClick(18, 24, 0xafafaf)
    -- end
end
-- 检查红点
function checkRed()
    if isColor(855, 80, 0xb0080a, 95) then
        tiaoShi("邮件红点")
        touchClick(829, 100, 0xd8caad)
    end
end
-- 执行目标
function doTarget()
    -- if muBiao == mb_GuaJi then
    --     if haoLV == 1 then
    --         gaiMuBiao(1, mb_ZhuXian, mm_ZhuXian)
    --     elseif haoLV >= 2 then
    --         gaiMuBiao(1, mb_EveryDay, mm_EveryDay)
    --     end
    -- elseif muBiao == mb_YouHua then
    --     task_JiDi()
    -- elseif muBiao == mb_ZhuXian then
    --     task()
    --     zhuXian()
    -- elseif muBiao == mb_WaKuang then
    --     waKuang()
    -- elseif muBiao == mb_ChuHang then
    --     chuHang()
    -- elseif muBiao == mb_FixShip then
    --     fixShip()

    -- elseif muBiao1 == mb_EveryDay then
    --     everyDayTask()
    -- end
end

-- 日常
function everyDayTask()
    -- if muBiao2 == var.mb_Wu then
    --     gaiMuBiao(2, mb_5DaoJu, mm_5DaoJu)
    -- end
    -- if var.muBiao == mb_5DaoJu then
    -- elseif var.muBiao == mb_CaiJi then
    -- elseif var.muBiao == mb_Reward then
    -- elseif var.muBiao == mb_JiNeng then
    -- end

end

-- 定时重置
function timeChongZhi()
    -- if isShengChan == false then
    --     if nowTime - timeShengChan >= 60 * 60 * 2 then
    --         isShengChan = true
    --         timeShengChan = nowTime
    --     end
    -- end
    -- if isChongDianKaZiYuan == true then
    --     if nowTime - timeChongDian >= 4 * 60 * 60 then
    --         timeChongDian = nowTime
    --         isChongDianKaZiYuan = false
    --     end
    -- end
end
-- 5分钟不见某界面
function checkXXX(...)
    -- if isColorPlus(1020, 545, 0x744218, 95) and isColorPlus(1123, 619, 0x744218, 95) then -- 有右下角的灰色块
    --     timeXXX = nowTime
    -- end
    -- if isColorPlus(69, 23, 0xff6600, 95) and isColorPlus(59, 579, 0x00428c, 95) then -- 左上角有基地现况
    --     timeXXX = nowTime
    -- end
    -- if haoLV == 3 then
    --     if nowTime - timeXXX >= 5 * 60 then
    --         current_time = os.date("%m-%d_%H.%M", os.time());
    --         snapshot(iphoneId .. "-" .. current_time .. ".png", 0, 0, 1135, 639); -- 以时间戳命名进行截图
    --         ftpUpPNG(iphoneId .. "-" .. current_time .. ".png", "OVER/")
    --         delFile(userPath() .. "/res/" .. iphoneId .. "-" .. current_time .. ".png")
    --         closeApp(appXiangMu)
    --         timeXXX = nowTime

    --         -- numDiaoXian = numDiaoXian + 1
    --         -- writePlist(luaMuLu .. xiangMu .. ".plist", "numDiaoXian", numDiaoXian)
    --         -- if numDiaoXian >= 6 then
    --         --     numDiaoXian = 0
    --         --     writePlist(luaMuLu .. xiangMu .. ".plist", "numDiaoXian", numDiaoXian)
    --         --     numDiaoXianDengDai = numDiaoXianDengDai + 1
    --         --     writePlist(luaMuLu .. xiangMu .. ".plist", "numDiaoXianDengDai", numDiaoXianDengDai)
    --         --     -- dialog("掉线6次,等一小时",60*60)
    --         -- end

    --     end
    -- else
    --     if nowTime - timeXXX >= 10 * 60 then
    --         current_time = os.date("%m-%d_%H.%M", os.time());
    --         snapshot(iphoneId .. "-" .. current_time .. ".png", 0, 0, 1135, 639); -- 以时间戳命名进行截图
    --         ftpUpPNG(iphoneId .. "-" .. current_time .. ".png", "OVER/")
    --         delFile(userPath() .. "/res/" .. iphoneId .. "-" .. current_time .. ".png")
    --         closeApp(appXiangMu)
    --         timeXXX = nowTime

    --     end
    -- end
end

-- 重置基地现况
function chongZhiJiDiXianKuang()
    -- gaiMuBiao(3, var.mb_Wu, mm_Wu)
    -- timeInside = nowTime

    -- numSearch = 0
    -- isLiZi = false -- 粒子
    -- isJustBack = true
    -- numSearchLiZi = 0
    -- numSearchLiZiSecond = 20

    -- if IsAgainReward == false then
    --     if nowDateTime.hour >= 22 and nowDateTime.min >= 0 then
    --         if var.muBiao == var.mb_WaKuang then
    --             gaiMuBiao(1, var.mb_EveryDay, mm_EveryDay)
    --             gaiMuBiao(2, mb_Reward, mm_Reward)

    --             IsAgainReward = true
    --             writePlist(var.luaMuLu .. var.xiangMu .. ".plist", "再次收获", IsAgainReward)
    --         end

    --     end
    -- end
    -- if haoLV == 2 then
    --     if var.muBiao == var.mb_WaKuang and nowTime - timeRound >= 1 * 60 * 60 then
    --         gaiMuBiao(1, var.mb_YouHua, mm_YouHua)
    --         timeRound = nowTime
    --     end
    -- end

end
-- 主线
function zhuXian()
end
-- 城内
function inside()
    if isColor(1091, 62, 0xa71f13, 95) and isColor(1103, 39, 0xc99565, 95) then
        return true
    else
        return false
    end
end
-- 每日重置
function everyDayInit(...)
    -- if nowDateTime.day ~= nowDayNight and nowDateTime.hour >= 23 and nowDateTime.min >= 55 then
    --     tiaoShi("晚重置")
    --     nowDayNight = nowDateTime.day
    --     writePlist(luaMuLu .. xiangMu .. ".plist", "日期晚", nowDayNight)
    --     numJiaoYi = 0
    --     writePlist(luaMuLu .. xiangMu .. ".plist", "交易次数", numJiaoYi)
    --     numJiaoYiChaoShi = 0
    --     writePlist(luaMuLu .. xiangMu .. ".plist", "交易超时", numJiaoYiChaoShi)
    -- end
    -- if numQuanShu ~= 0 then
    -- local tmpXuanXiang = string.find(duoXuan1, "1")
    -- if tmpXuanXiang ~= nil then

    -- if nowDateTime.day ~= nowDay then
    --     if nowDateTime.hour >= 8 and nowDateTime.min >= 0 then
    --         tiaoShi("8点0分重置")

    --         -- closeApp(appXiangMu)

    --         nowDay = nowDateTime.day
    --         writePlist(luaMuLu .. xiangMu .. ".plist", "日期", nowDay)

    --         numDay = numDay + 1
    --         writePlist(luaMuLu .. xiangMu .. ".plist", "第几天", numDay)

    --         numGuangGao = 0
    --         writePlist(luaMuLu .. xiangMu .. ".plist", "广告次数", numGuangGao)

    --         numChuanShu = 0
    --         writePlist(luaMuLu .. xiangMu .. ".plist", "传输次数", numChuanShu)

    --         isTrade = false
    --         writePlist(luaMuLu .. xiangMu .. ".plist", "交易行", isTrade)

    --         num5DaoJu = 0
    --         writePlist(luaMuLu .. xiangMu .. ".plist", "每日5道具", num5DaoJu)

    --         numAddChanLiang = 0
    --         writePlist(luaMuLu .. xiangMu .. ".plist", "增产", numAddChanLiang)

    --         isAgainReward = false
    --         writePlist(luaMuLu .. xiangMu .. ".plist", "再次收获", isAgainReward)

    --         num3Pirate = 0
    --         writePlist(luaMuLu .. xiangMu .. ".plist", "每日3海盗", num3Pirate)

    --         isKaYouHua = false
    --         writePlist(luaMuLu .. xiangMu .. ".plist", "卡优化", isKaYouHua)

    --         if haoLV >= 2 then
    --             gaiMuBiao(1, mb_EveryDay, mm_EveryDay)
    --             gaiMuBiao(2, mb_Wu, mm_Wu)
    --             gaiMuBiao(3, mb_Wu, mm_Wu)
    --         end

    --         -- today = tonumber(os.date("%w",os.time()))
    --         -- if today == 1 then --如果是星期一
    --         --         if APP1.isZhuZhan == 2 then
    --         --                 APP1.isZhuZhan = 1
    --         --                 writePlist(luaMuLu..xiangMu..".plist","助战1",APP1.isZhuZhan)
    --         --         end
    --         --         if APP2.isZhuZhan == 2 then
    --         --                 APP2.isZhuZhan = 1
    --         --                 writePlist(luaMuLu..xiangMu..".plist","助战2",APP2.isZhuZhan)
    --         --         end
    --         --         if APP1.isJiFenDuiHuan == 1 then
    --         --                 APP1.isJiFenDuiHuan = 0
    --         --                 writePlist(luaMuLu..xiangMu..".plist","积分兑换1",APP1.isJiFenDuiHuan)
    --         --         end
    --         --         if APP2.isJiFenDuiHuan == 1 then
    --         --                 APP2.isJiFenDuiHuan = 0
    --         --                 writePlist(luaMuLu..xiangMu..".plist","积分兑换2",APP2.isJiFenDuiHuan)
    --         --         end
    --         -- end
    --         -- closeApp(appXiangMu)
    --         -- numJiaoSe = 0
    --         -- writePlist(luaMuLu .. xiangMu .. ".plist", "角色", numJiaoSe)
    --         -- huanJiaoSeChongZhi()
    --         -- timeMaiLan = nowTime
    --         -- writePlist(luaMuLu .. xiangMu .. ".plist", "timeMaiLan", timeMaiLan)

    --         -- isWeiXinWeiHu = false
    --         -- writePlist(luaMuLu .. xiangMu .. ".plist", "微信维护", isWeiXinWeiHu)
    --         -- hourWeiXin = random(10, 22)
    --         -- minWeiXin = random(1, 50)
    --         -- writePlist(luaMuLu .. xiangMu .. ".plist", "时", hourWeiXin)
    --         -- writePlist(luaMuLu .. xiangMu .. ".plist", "分", minWeiXin)

    --         -- gaiMuBiao(1, mb_YouHua, mm_YouHua)
    --     end
    -- end
    -- end
    -- end
end
-- 小号判定
function isXiaoHao()
    -- if haoLV == 1 and inside() then
    --     if isColorPlus(225, 92, 0x9d1111, 95) then
    --         haoLV = 2
    --     end
    -- end
end
-- 识字--数字
-- function ocrNumbers()

-- 请自行更改参数
-- 1: 0,0,0,0 范围坐标，请自行修改
-- 2: "B5B6BD , 4A4A42" 偏色,多组或单组.请在偏色列表中选择
-- 3: 90 匹配精度 【0-100】

-- ret_num = tsOcrText(index_num, 947, 15, 1015, 30, "B5B6BD,4A4A42", 90)
-- tiaoShi("粒子:" .. ret_num)

-- end

-- 识数
function OCR_num()
    -- 光学识字
    -- numLiZi = ocrText(947, 15, 1005, 30, 0, "0123456789.")
    -- tiaoShi("粒子:" .. numLiZi)

    -- 大漠识字
    -- 相同字库只需要加载一次，重复加载会导致内存溢出
    -- 由于大漠工具的 11 行像素限制，对于较大文字识别效率不高，推荐使用触动字库工具配合触动文字识别函数使用效果更佳
    -- numLiZi = dmOcrText(dm_num, 947, 15, 1017, 30, "D7D7DB , 282824", 90)
    -- tiaoShi(numLiZi)

    -- by新版不支持
    -- by.UseDict(dictNum)
    -- numLiZi = by.Ocr(947, 16, 1017, 28, 0xdadade, 0x252521, 0.9) -- 粒子
    -- tiaoShi(text)
    -- return text
    -- numLiZi = shiZi(dm_num,947, 16, 1017, 28, 0xdadade,0x252521,85)
    -- tiaoShi(numLiZi)
    -- local tmpYinLiang = shiZi(dm_num,87, 522, 769, 542,0xdcdee1,0x333333,85)

    -- 触动识字
    -- numLiZi = tsOcrText(index_cd_num, 947, 15, 1015, 30, "D7D7DB , 282824", 90)
    -- tiaoShi(numLiZi)

    -- 百度识字
    -- local pic_name = userPath() .. "/res/baiduAI.jpg"
    -- snapshot(pic_name, 947, 15, 1015, 30) 
    -- mSleep(1000)
    -- --tab 参数仅支持 v1.3.3 及其以上版本 TSLib
    -- local tab={
    --     language_type="ENG",
    --     detect_direction="false",
    --     detect_language="false",
    --     paragraph="false",
    --     probability="false",
    --     ocrType = 1
    -- }
    -- local code1, access_token = getAccessToken(baidu_API, baidu_Secret)
    -- if code1 then
    --     -- tiaoShi("获取成功:" .. access_token)
    --     local code2, body = baiduAI(access_token, pic_name, tab)
    --     if code2 then
    --         tiaoShi("识别成功\n" .. body)
    --     else
    --         tiaoShi("识别失败\n" .. body)
    --     end
    -- else
    --     tiaoShi("获取失败:" .. access_token)
    -- end

end

-- {"words_result":[{"words":"95.6K"}],"words_result_num":1,"log_id":1509749838368023749} 
chuCiJiaZai()
while var.isRound == 1 do
    main1()
end
var.isRound = 2
